import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myapp/app/theme/app_color.dart';

class ProfileUserLayout extends StatelessWidget {
  final String avatar =
      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13926895099%2F641&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1632797230&t=b5cfeaf64f4237bebd957a536dfc3846";

  final EdgeInsets? margin;

  ProfileUserLayout({this.margin});

  Widget _buildHeader() {
    return Container(
      margin: margin,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Container(
            child: ClipRRect(
                child: Image.network(
                  avatar,
                  fit: BoxFit.cover,
                ),
                borderRadius: BorderRadius.circular(30)),
            width: 60,
            height: 60,
            margin: EdgeInsets.only(right: 20),
          ),
          Text(
            "Violet",
            style: TextStyle(
                fontSize: 18,
                color: AppColor.hex_333,
                fontWeight: FontWeight.bold),
          ),
          Expanded(
              child: Text(
            "个人主页 >",
            style: TextStyle(fontSize: 12, color: AppColor.hex_666),
            textAlign: TextAlign.end,
          )),
        ],
      ),
      width: double.infinity,
    );
  }

  Widget _buildStatisticsItem(String count, String type) {
    return Text.rich(
      TextSpan(
          text: count,
          style: TextStyle(fontSize: 14, color: AppColor.hex_333, fontWeight: FontWeight.bold, height: 1.5),
          children: [
            TextSpan(
                text: "\n$type",
                style: TextStyle(fontSize: 12, color: AppColor.hex_666))
          ]),
      textAlign: TextAlign.center,
    );
  }

  Widget _buildStatistics() {
    return Container(
      margin: EdgeInsets.only(top: 10),
      child: Row(
        children: [
          Expanded(child: _buildStatisticsItem("377", "头条")),
          Expanded(child: _buildStatisticsItem("3万", "获赞")),
          Expanded(child: _buildStatisticsItem("72", "粉丝")),
          Expanded(child: _buildStatisticsItem("311", "关注")),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [_buildHeader(), _buildStatistics()],
    );
  }
}
